using System.Linq;
using UnityEngine;
using UnityEngine.UI;

namespace MaterialUI
{
	public class EmptyUIObjectInstantiationHelper : InstantiationHelper
	{
		public const int optionHasLayoutHorizontal = 0;

		public const int optionHasLayoutVertical = 1;

		public const int optionFitted = 2;

		public const int optionStretched = 3;

		[SerializeField]
		private RectTransform m_RectTransform;

		[SerializeField]
		private ContentSizeFitter m_SizeFitter;

		[SerializeField]
		private LayoutGroup m_LayoutGroup;

		public override void HelpInstantiate(int[] options)
		{
			if (!options.Contains(0) && !options.Contains(1))
			{
				UnityEngine.Object.DestroyImmediate(m_LayoutGroup);
			}
			else if (options.Contains(0))
			{
				GameObject gameObject = m_LayoutGroup.gameObject;
				UnityEngine.Object.DestroyImmediate(m_LayoutGroup);
				m_LayoutGroup = gameObject.AddComponent<HorizontalLayoutGroup>();
				m_LayoutGroup.childAlignment = TextAnchor.MiddleCenter;
				((HorizontalLayoutGroup)m_LayoutGroup).childForceExpandWidth = false;
				((HorizontalLayoutGroup)m_LayoutGroup).childForceExpandHeight = false;
			}
			else
			{
				m_LayoutGroup = m_RectTransform.gameObject.GetAddComponent<VerticalLayoutGroup>();
				m_LayoutGroup.childAlignment = TextAnchor.MiddleCenter;
				((VerticalLayoutGroup)m_LayoutGroup).childForceExpandWidth = false;
				((VerticalLayoutGroup)m_LayoutGroup).childForceExpandHeight = false;
			}
			if (!options.Contains(2))
			{
				UnityEngine.Object.DestroyImmediate(m_SizeFitter);
				m_RectTransform.sizeDelta = new Vector2(100f, 100f);
				m_RectTransform.anchoredPosition = Vector2.zero;
			}
			if (options.Contains(3))
			{
				m_RectTransform.anchorMin = new Vector2(0f, 0f);
				m_RectTransform.anchorMax = new Vector2(1f, 1f);
				m_RectTransform.sizeDelta = Vector2.zero;
				m_RectTransform.anchoredPosition = Vector2.zero;
			}
			base.HelpInstantiate(options);
		}
	}
}
